package com.design.pattern.compound;

import java.util.ArrayList;
import java.util.Iterator;

public class Flock implements Quackable {
    ArrayList quackables = new ArrayList();
    Observable observable;

    public Flock() {
        observable = new Observable(this);
    }

    void add(Quackable duck) {
        quackables.add(duck);
    }

    public void quack() {
        Iterator iterator = quackables.iterator();
        while (iterator.hasNext()) {
            Quackable quackable = (Quackable) iterator.next();
            quackable.quack();
        }
    }

    public void registerObserver(Observer observer) {
        Iterator iterator = quackables.iterator();
        while (iterator.hasNext()) {
            Quackable quackable = (Quackable) iterator.next();
            quackable.registerObserver(observer);
        }
    }

    public void notifyObservers() {

    }
}